home *** CD-ROM | disk | FTP | other *** search
- program DemoSv2;
-
- {==============================================================================}
- { NT service which demonstrates multiple services in a process. }
- { }
- { This was written by John Chaytor and accompanies an aticle in 'The Delphi }
- { Magazine'. See that article for a detailed discussion of NT services. }
- { }
- {==============================================================================}
- Uses SysUtils, Classes, Windows, SvcClass, Services, Logging;
-
- procedure DisplayVersionDetails;
- begin
- WriteLn('DemoSv2 Version 1.00');
- end;
-
- procedure DisplaySyntaxOptions;
- begin
- WriteLn('');
- WriteLn('Command syntax options :-');
- WriteLn('');
- WriteLn('DemoSv2 INSTALL');
- WriteLn('DemoSv2 INSTALL <service1> <service2> ...');
- WriteLn('DemoSv2 UNINSTALL');
- WriteLn('DemoSv2 UNINSTALL <service1> <service2> ...');
- WriteLn('DemoSv2 VERSION');
- WriteLn('');
- WriteLn('Do not execute this program without passing a parameter.');
- WriteLn('If you attempt this an error will occur as the program');
- WriteLn('assumes it is running under the control of the SCM.');
- WriteLn('');
- end;
-
- var
- I: Integer;
- Option: ShortString;
- ServiceController: TNTServiceController;
- ServiceList: TStrings;
-
- begin
- ServiceController := TNTServiceControllerDemo.Create;
- try
- Option := UpperCase(ParamStr(1));
- ServiceList := TStringList.Create;
- For I := 2 to ParamCount do
- ServiceList.Add(UpperCase(ParamStr(I)));
- With ServiceController do
- try
- RegisterService(TService2a);
- RegisterService(TService2b);
- RegisterService(TService2c);
- if Option = '' then
- Connect
- else
- if (Option = 'INSTALL') or (Option = 'I') then
- InstallServices(ServiceList)
- else
- if (Option = 'UNINSTALL') or (Option = 'U') then
- UninstallServices(ServiceList)
- else
- if (Option = 'VERSION') or (Option = 'V') then
- DisplayVersionDetails
- else
- DisplaySyntaxOptions;
- finally
- ServiceList.Free;
- end;
- finally
- ServiceController.Free;
- end;
- end.
-